<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:import href="../utilities/master-calendar.xsl"/>
<xsl:import href="../utilities/date-and-time.xsl"/>
<xsl:import href="../utilities/get-client-info.xsl"/>
<xsl:import href="../utilities/get-admin-menu.xsl"/>

<xsl:param name="client" select="/data/events/front-end-authentication/@user"/>
<xsl:param name="current-root" select="concat($root,'/',$current-page)"/>

<xsl:template match="data">
	<xsl:param name="is-today">
		<xsl:choose>
			<xsl:when test="not($year) or $year='today' or $today = concat($year,'-',$month,'-',$day)">1</xsl:when>
			<xsl:otherwise>0</xsl:otherwise>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="not-month">
		<xsl:choose>
			<xsl:when test="not($month)">1</xsl:when>
			<xsl:otherwise>0</xsl:otherwise>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="not-day">
		<xsl:choose>
			<xsl:when test="not($day)">1</xsl:when>
			<xsl:otherwise>0</xsl:otherwise>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="date">
		<xsl:choose>
			<xsl:when test="not($year) or $year='today'">
				<xsl:value-of select="$today"/>
			</xsl:when>
			<xsl:when test="$year and not($month)">
				<xsl:value-of select="concat($year,'-01-00')"/>
			</xsl:when>
			<xsl:when test="$year and $month and not($day)">
				<xsl:value-of select="concat($year,'-',$month,'-00')"/>
			</xsl:when>
			<xsl:when test="$year and $month and $day">
				<xsl:value-of select="concat(format-number($year,'0000'),'-',format-number($month,'00'),'-',format-number($day,'00'))"/>
			</xsl:when>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="day">
		<xsl:choose>
			<xsl:when test="not($year) or $year='today'">
				<xsl:value-of select="substring($date,9,2)"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="format-number($day,'00')"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="month">
		<xsl:choose>
			<xsl:when test="not($year) or $year='today'">
				<xsl:value-of select="substring($date,6,2)"/>
			</xsl:when>
			<xsl:when test="not($month) and $year!='today'">
				<xsl:value-of select="'01'"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="format-number($month,'00')"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="year">
		<xsl:choose>
			<xsl:when test="not($year) or $year='today'">
				<xsl:value-of select="substring($date,1,4)"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="format-number($year,'0000')"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="month-days">
		<xsl:call-template name="month-days">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="next-month-days">
		<xsl:call-template name="next-month-days">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="previous-month-days">
		<xsl:call-template name="previous-month-days">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="previous-week">
		<xsl:call-template name="previous-week">
			<xsl:with-param name="date" select="concat($year,'-',$month,'-',$day)"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="next-week">
		<xsl:call-template name="next-week">
			<xsl:with-param name="date" select="concat($year,'-',$month,'-',$day)"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="next-day">
		<xsl:call-template name="next-day">
			<xsl:with-param name="date" select="$date"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="current-date-url">
		<xsl:choose>
			<xsl:when test="$is-today = 1">
				<xsl:value-of select="concat($year,'/',$month,'/',$day,'/')"/>
			</xsl:when>
			<xsl:when test="$year and $not-month = 1">
				<xsl:value-of select="concat($year,'/')"/>
			</xsl:when>
			<xsl:when test="$year and $month and $not-day = 1">
				<xsl:value-of select="concat($year,'/',$month,'/')"/>
			</xsl:when>
			<xsl:when test="$year and $month and $day = 0">
				<xsl:value-of select="concat($year,'/',$month,'/')"/>
			</xsl:when>
			<xsl:when test="$year and $month and $day &gt; 0">
				<xsl:value-of select="concat($year,'/',$month,'/',$day,'/')"/>
			</xsl:when>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="next-day-url">
		<xsl:value-of select="concat(substring($next-day,1,4),'/',substring($next-day,6,2),'/',substring($next-day,9,2))"/>
	</xsl:param>
	<xsl:param name="previous-week-url">
		<xsl:value-of select="concat(substring($previous-week,1,4),'/',substring($previous-week,6,2),'/',substring($previous-week,9,2))"/>
	</xsl:param>
	<xsl:param name="next-week-url">
		<xsl:value-of select="concat(substring($next-week,1,4),'/',substring($next-week,6,2),'/',substring($next-week,9,2))"/>
	</xsl:param>
	<xsl:param name="previous-year-url">
		<xsl:choose>
			<xsl:when test="$is-today = 1">
				<xsl:value-of select="concat($year - 1,'/',$month,'/',substring($date,9,2))"/>
			</xsl:when>
			<xsl:when test="$year and $not-month = 1">
				<xsl:value-of select="$year - 1"/>
			</xsl:when>
			<xsl:when test="$year and $month and $not-day = 1">
				<xsl:value-of select="concat($year - 1,'/',$month)"/>
			</xsl:when>
			<xsl:when test="$year and $month and $day and $day = 0">
				<xsl:value-of select="concat($year - 1,'/',$month)"/>
			</xsl:when>
			<xsl:when test="$year and $month and $day and $day > 0">
				<xsl:value-of select="concat($year - 1,'/',$month,'/',$day)"/>
			</xsl:when>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="next-year-url">
		<xsl:choose>
			<xsl:when test="$is-today = 1">
				<xsl:value-of select="concat($year + 1,'/',$month,'/',substring($date,9,2))"/>
			</xsl:when>
			<xsl:when test="$year and $not-month = 1">
				<xsl:value-of select="$year + 1"/>
			</xsl:when>
			<xsl:when test="$year and $month and $not-day = 1">
				<xsl:value-of select="concat($year + 1,'/',$month)"/>
			</xsl:when>
			<xsl:when test="$year and $month and $day and $day = 0">
				<xsl:value-of select="concat($year + 1,'/',$month)"/>
			</xsl:when>
			<xsl:when test="$year and $month and $day and $day > 0">
				<xsl:value-of select="concat($year + 1,'/',$month,'/',$day)"/>
			</xsl:when>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="previous-month-url">
		<xsl:choose>
			<xsl:when test="$month - 1 &lt; 1">
				<xsl:choose>
					<xsl:when test="$is-today = 1">
						<xsl:value-of select="concat($year - 1,'/12/',substring($date,9,2))"/>
					</xsl:when>
					<xsl:when test="($year and $not-month = 1) or ($year and $month and $not-day = 1)">
						<xsl:value-of select="concat($year - 1,'/12')"/>
					</xsl:when>
					<xsl:when test="$year and $month and $day">
						<xsl:value-of select="concat($year - 1,'/12/',$day)"/>
					</xsl:when>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="$is-today = 1">
						<xsl:value-of select="concat($year,'/',format-number($month - 1,'00'),'/',substring($date,9,2))"/>
					</xsl:when>
					<xsl:when test="$year and $not-month = 1">
						<xsl:value-of select="concat($year,'/',format-number($month - 1,'00'))"/>
					</xsl:when>
					<xsl:when test="$year and $month and $not-day = 1">
						<xsl:value-of select="concat($year,'/',format-number($month - 1,'00'))"/>
					</xsl:when>
					<xsl:when test="$year and $month and $day = 0">
						<xsl:value-of select="concat($year,'/',format-number($month - 1,'00'))"/>
					</xsl:when>
					<xsl:when test="$year and $month and $day &gt; 0 and $day &lt;= $previous-month-days">
						<xsl:value-of select="concat($year,'/',format-number($month - 1,'00'),'/',$day)"/>
					</xsl:when>
					<xsl:when test="$year and $month and $day &gt; $previous-month-days">
						<xsl:value-of select="concat($year,'/',format-number($month - 1,'00'),'/',$previous-month-days)"/>
					</xsl:when>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="next-month-url">
		<xsl:choose>
			<xsl:when test="$month + 1 &gt; 12">
				<xsl:choose>
					<xsl:when test="$is-today = 1">
						<xsl:value-of select="concat($year + 1,'/01/',substring($date,9,2))"/>
					</xsl:when>
					<xsl:when test="($year and $not-month = 1) or ($year and $month and $not-day = 1)">
						<xsl:value-of select="concat($year + 1,'/01')"/>
					</xsl:when>
					<xsl:when test="$year and $month and $day">
						<xsl:value-of select="concat($year + 1,'/01/',$day)"/>
					</xsl:when>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="$is-today = 1">
						<xsl:value-of select="concat($year,'/',format-number($month + 1,'00'),'/',substring($date,9,2))"/>
					</xsl:when>
					<xsl:when test="$year and $not-month = 1">
						<xsl:value-of select="concat($year,'/',format-number($month + 1,'00'))"/>
					</xsl:when>
					<xsl:when test="$year and $month and $not-day = 1">
						<xsl:value-of select="concat($year,'/',format-number($month + 1,'00'))"/>
					</xsl:when>
					<xsl:when test="$year and $month and $day = 0">
						<xsl:value-of select="concat($year,'/',format-number($month + 1,'00'))"/>
					</xsl:when>
					<xsl:when test="$year and $month and $day &gt; 0 and $day &lt;= $next-month-days">
						<xsl:value-of select="concat($year,'/',format-number($month + 1,'00'),'/',$day)"/>
					</xsl:when>
					<xsl:when test="$year and $month and $day &gt; $next-month-days">
						<xsl:value-of select="concat($year,'/',format-number($month + 1,'00'),'/',$next-month-days)"/>
					</xsl:when>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="previous-month-date">
		<xsl:choose>
			<xsl:when test="$month - 1 &lt; 1">
				<xsl:value-of select="concat($year - 1,'-12-00')"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="concat($year,'-',format-number($month - 1,'00'),'-00')"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="next-month-date">
		<xsl:choose>
			<xsl:when test="$month + 1 &gt; 12">
				<xsl:value-of select="concat($year + 1,'-01-00')"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="concat($year,'-',format-number($month + 1,'00'),'-00')"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:param>

<!-- XXXX HTML XXXX -->
	<xsl:choose>
		<xsl:when test="$year = 'NaN' or $year &lt; 1001 or $year &gt; 3000 or $month &gt; 12 or $month &lt; 1 or $day &gt; 31 or $day &lt; 1">
			<div class="grid_8 error">
				<h2>Calendar</h2>
				<h4>Not a Valid Date</h4>
				<p>Please enter a date in the address fields in the form of /calendar/yyyy/mm/dd/ to view a calendar. Or you can find out what the date is <a href="{$current-root}/today/">today</a>. (This calendar does not calculate dates previous to 1,001 AD or greater than 3,000 AD.)</p>
			</div>
		</xsl:when>
		<xsl:otherwise>
<!-- xxxx FIXIN' HERE xxxx -->
			<xsl:choose>
				<xsl:when test="/data/clients/entry/administrator = 'Yes'">
					<div class="grid_16" id="admin">
						<div class="grid_5 alpha">
							<xsl:call-template name="admin-menu"/>
						</div>
						<div class="grid_11 omega">
							<div class="calendar-head">
								<h2>
									<xsl:call-template name="get-formatted-month">
										<xsl:with-param name="month" select="$month"/>
									</xsl:call-template>
									<xsl:text></xsl:text>
									<xsl:value-of select="$year"/>
								</h2>
							</div>
							<div class="calendar-head">
								<ul class="calendar-menu">
									<li id="month_prev">
										<a href="{$current-root}/{$previous-month-url}/">Previous Month</a>
									</li>
									<li id="month_today">
										<xsl:if test="$is-today = 1">
											<xsl:attribute name="class">
												<xsl:value-of select="'current'"/>
											</xsl:attribute>
										</xsl:if>
										<a href="{$current-root}/{$this-year}/{$this-month}/{$this-day}/">Today</a>
									</li>
									<li id="month_next">
										<a href="{$current-root}/{$next-month-url}/">Next Month</a>
									</li>
								</ul>
							</div>
							<div class="calendar current-month">
								<xsl:call-template name="calendar-month">
									<xsl:with-param name="year" select="substring($date,1,4)"/>
									<xsl:with-param name="month" select="substring($date,6,2)"/>
									<xsl:with-param name="day" select="substring($date,9,2)"/>
								</xsl:call-template>
							</div>
						</div>
					</div>
				</xsl:when>
				<xsl:otherwise>
					<div class="grid_16">
						<div class="grid_5 alpha">
							<xsl:call-template name="client-info"/>
						</div>
						<xsl:choose>
							<xsl:when test="/data/clients/entry/client-status/item/@handle = 'suspended'">
								<div class="grid_10 omega">
									<div class="calendar-head">
										<h2>
											<xsl:text>Sorry, but your account has been </xsl:text>
											<strong>
												<xsl:value-of select="/data/clients/entry/client-status/item"/>
											</strong>
										</h2>
										<p>You are only permitted to view your current <a href="{$root}/profile">Profile</a> information and <a href="{$root}/archives">Archives</a> of your past appointments. Please contact <xsl:value-of select="$website-name"/> directly at <strong>(541) 231-1118</strong> if you wish to schedule an appointment.</p>
									</div>
								</div>
							</xsl:when>
							<xsl:when test="/data/clients/entry/client-status/item/@handle = 'closed'">
								<div class="grid_10 omega">
									<div class="calendar-head">
										<h2>
											<xsl:text>Sorry, but your account has been </xsl:text>
											<strong>
												<xsl:value-of select="/data/clients/entry/client-status/item"/>
											</strong>
										</h2>
										<p>You are only permitted to view <a href="{$root}/archives">Archives</a> of your past appointments. Please contact <xsl:value-of select="$website-name"/> directly at <strong>(541) 231-1118</strong> if you wish to schedule an appointment.</p>
									</div>
								</div>
							</xsl:when>
							<xsl:otherwise>
								<div class="grid_11 omega" id="cal">
									<div class="calendar-head">
										<h2>
											<xsl:call-template name="get-formatted-month">
												<xsl:with-param name="month" select="$month"/>
											</xsl:call-template>
											<xsl:text></xsl:text>
											<xsl:value-of select="$year"/>
										</h2>
									</div>
									<div class="calendar-head">
										<ul class="calendar-menu">
											<li id="month_prev">
												<a href="{$current-root}/{$previous-month-url}/">Previous Month</a>
											</li>
											<li id="month_today">
												<xsl:if test="$is-today = 1">
													<xsl:attribute name="class">
														<xsl:value-of select="'current'"/>
													</xsl:attribute>
												</xsl:if>
												<a href="{$current-root}/{$this-year}/{$this-month}/{$this-day}/">Today</a>
											</li>
											<li id="month_next">
												<a href="{$current-root}/{$next-month-url}/">Next Month</a>
											</li>
										</ul>
									</div>
									<div class="calendar current-month">
										<xsl:call-template name="calendar-month">
											<xsl:with-param name="year" select="substring($date,1,4)"/>
											<xsl:with-param name="month" select="substring($date,6,2)"/>
											<xsl:with-param name="day" select="substring($date,9,2)"/>
										</xsl:call-template>
									</div>
								</div>
							</xsl:otherwise>
						</xsl:choose>
					</div>
				</xsl:otherwise>
			</xsl:choose>
			
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
<!-- HTML -->

<xsl:template name="calendar-month">
	<xsl:param name="year" select="$year"/>
	<xsl:param name="month" select="$month"/>
	<xsl:param name="day" select="$day"/>
	<xsl:param name="weekday-format"/>
	<table summary="calendar">
		<thead>
			<tr>
				<xsl:choose>
					<xsl:when test="$weekday-format='one-letter'">
						<th>S</th>
						<th>M</th>
						<th>T</th>
						<th>W</th>
						<th>T</th>
						<th>F</th>
						<th>S</th>
					</xsl:when>
					<xsl:when test="$weekday-format='short'">
						<th>Sun</th>
						<th>Mon</th>
						<th>Tue</th>
						<th>Wed</th>
						<th>Thu</th>
						<th>Fri</th>
						<th>Sat</th>
					</xsl:when>
					<xsl:otherwise>
						<th>Sunday</th>
						<th>Monday</th>
						<th>Tuesday</th>
						<th>Wednesday</th>
						<th>Thursday</th>
						<th>Friday</th>
						<th>Saturday</th>
					</xsl:otherwise>
				</xsl:choose>
			</tr>
		</thead>
		<tbody>
			<xsl:call-template name="month">
				<xsl:with-param name="year" select="$year"/>
				<xsl:with-param name="month" select="$month"/>
				<xsl:with-param name="day" select="$day"/>
			</xsl:call-template>
		</tbody>
	</table>
</xsl:template>
<!-- Called only once for root -->
<!-- Uses recursion with index + 7 for each week -->
<xsl:template name="month">
	<xsl:param name="year" select="'2007'"/>
	<xsl:param name="month" select="'07'"/>
	<xsl:param name="day" select="'24'"/>
	<xsl:param name="date" select="concat($year,'-',$month,'-',$day)"/>
	<xsl:param name="first-day-of-the-month" select="concat($year,'-',$month,'-01')"/>
	<xsl:param name="leap-year">
		<xsl:call-template name="is-leap-year">
			<xsl:with-param name="year" select="$year"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="first-day">
		<xsl:call-template name="calculate-day-of-the-week">
			<xsl:with-param name="date" select="$first-day-of-the-month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="month-days">
		<xsl:call-template name="month-days">
			<xsl:with-param name="month" select="$month"/>
			<xsl:with-param name="leap-year" select="$leap-year"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="start" select="$first-day"/>
	<xsl:param name="count" select="$month-days"/>
	<xsl:param name="total" select="$start + $count - 1"/>
	<xsl:param name="overflow" select="$total mod 7"/>
	<xsl:param name="nelements">
		<xsl:choose>
			<xsl:when test="$overflow &gt; 0">
				<xsl:value-of select="$total + 7 - $overflow"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$total"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="index" select="1"/>
	<xsl:if test="$index &lt; $nelements">
		<xsl:call-template name="week">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
			<xsl:with-param name="day" select="$day"/>
			<xsl:with-param name="index" select="$index"/>
		</xsl:call-template>
		<xsl:call-template name="month">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
			<xsl:with-param name="day" select="$day"/>
			<xsl:with-param name="index" select="$index + 7"/>
		</xsl:call-template>
	</xsl:if>
</xsl:template>
<!-- Called repeatedly by month for each week -->
<xsl:template name="week">
	<xsl:param name="year" select="'2007'"/>
	<xsl:param name="month" select="'07'"/>
	<xsl:param name="day" select="'24'"/>
	<xsl:param name="index" select="1"/>
	<tr>
		<xsl:call-template name="days">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
			<xsl:with-param name="day" select="$day"/>
			<xsl:with-param name="index" select="$index"/>
			<xsl:with-param name="counter" select="$index + 6"/>
		</xsl:call-template>
	</tr>
</xsl:template>
<!-- Called by week -->
<!-- Uses recursion with index + 1 for each day-of-week -->
<xsl:template name="days">
	<xsl:param name="year" select="'2007'"/>
	<xsl:param name="month" select="'07'"/>
	<xsl:param name="day" select="'24'"/>
	<xsl:param name="first-day-of-the-month" select="concat($year,'-',$month,'-01')"/>
	<xsl:param name="first-day">
		<xsl:call-template name="calculate-day-of-the-week">
			<xsl:with-param name="date" select="$first-day-of-the-month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="month-days">
		<xsl:call-template name="month-days">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="start" select="$first-day"/>
	<xsl:param name="count" select="$month-days"/>
	<xsl:param name="total" select="$start + $count - 1"/>
	<xsl:param name="overflow" select="$total mod 7"/>
	<xsl:param name="nelements">
		<xsl:choose>
			<xsl:when test="$overflow &gt; 0">
				<xsl:value-of select="$total + 7 - $overflow"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$total"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="previous-month">
		<xsl:call-template name="previous-month">
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="previous-month-year">
		<xsl:call-template name="previous-month-year">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="next-month">
		<xsl:call-template name="next-month">
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="next-month-year">
		<xsl:call-template name="next-month-year">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="previous-month-days">
		<xsl:call-template name="month-days">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$previous-month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="index" select="1"/>
	<xsl:param name="counter" select="1"/>
	<xsl:param name="day-int" select="$index - $start + 1"/>
	<xsl:param name="day-dd" select="format-number($day-int,'00')"/>
	<xsl:param name="previous-day" select="$previous-month-days + $day-int"/>
	<xsl:param name="next-day" select="format-number($day-int - $month-days,'00')"/>
	<xsl:param name="this-date">
		<xsl:choose>
			<xsl:when test="$day-int &gt; 0 and $day-int &lt;= $month-days">
				<xsl:value-of select="concat($year,'-',$month,'-',$day-dd)"/>
			</xsl:when>
			<xsl:when test="$day-int &lt; 1">
				<xsl:value-of select="concat($previous-month-year,'-',$previous-month,'-',$previous-day)"/>
			</xsl:when>
			<xsl:when test="$day-int &gt; $month-days">
				<xsl:value-of select="concat($next-month-year,'-',$next-month,'-',$next-day)"/>
			</xsl:when>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="this-year" select="substring($this-date,1,4)"/>
	<xsl:param name="this-month" select="substring($this-date,6,2)"/>
	<xsl:param name="this-day" select="substring($this-date,9,2)"/>
	<xsl:param name="this-day-int" select="format-number($this-day,'0')"/>
	<xsl:param name="this-month-day" select="substring(translate($this-date, '-', ''),5)"/>
	<xsl:param name="is-today">
		<xsl:choose>
			<xsl:when test="$this-date = $today">1</xsl:when>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="is-past">
		<xsl:choose>
			<xsl:when test="translate($this-date, '-', '') &lt;= translate($today, '-', '')">1</xsl:when>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="is-holiday">
		<xsl:for-each select="iCalendar/vcalendar[@x-wr-calname='Holidays']/vevent[substring(dtstart,5) = $this-month-day][not(rrule/item/@class='byday') and rrule/item[@class='freq']='yearly']">
			<xsl:if test="substring(dtstart,5) = $this-month-day">1</xsl:if>
		</xsl:for-each>
	</xsl:param>
	<xsl:param name="is-vacation">
		<xsl:for-each select="vacations/entry[date-of-closure = $this-date]">
			<xsl:if test="date-of-closure = $this-date and status/item/@handle = 'active'">1</xsl:if>
		</xsl:for-each>
	</xsl:param>
	<xsl:param name="date" select="concat($this-year,'-',$this-month,'-',$this-day)"/>
	<xsl:param name="week-day">
		<xsl:call-template name="get-day-of-the-week-name">
			<xsl:with-param name="date" select="$date"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="is-blocked">
		<xsl:for-each select="time-schedule/entry[weekday = normalize-space($week-day)]">
			<xsl:if test="available-times/item/@handle = 'none'">1</xsl:if>
		</xsl:for-each>
	</xsl:param>
	<xsl:param name="is-a-full-day">
		<xsl:call-template name="full-day">
			<xsl:with-param name="date" select="normalize-space($date)"/>
		</xsl:call-template>
	</xsl:param>
	
	<!--xsl:param name="tomorrow-day" select="(substring($today,9) + 1)"/>
	<xsl:param name="tomorrow-month" select="substring($today,6,2)"/>
	<xsl:param name="tomorrow-year" select="substring($today,1,4)"/>
	<xsl:param name="tomorrow-date" select="concat($tomorrow-year,'-',$tomorrow-month,'-',$tomorrow-day)"/-->
	
	<xsl:param name="tomorrow">
		<xsl:call-template name="next-day">
			<xsl:with-param name="date" select="$today"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="is-tomorrow">
		<xsl:if test="$this-date = $tomorrow">1</xsl:if>
	</xsl:param>
	
	<xsl:choose>
		<xsl:when test="$index &lt; $start or normalize-space(substring($week-day,2)) = 'aturday' or normalize-space(substring($week-day,2)) = 'unday'">
			<xsl:if test="/data/clients/entry/administrator = 'No'">
				<td class="previous-month-day">
					<span>
						<xsl:value-of select="$this-day-int"/>
					</span>
				</td>
			</xsl:if>
			<xsl:if test="/data/clients/entry/administrator = 'Yes'">
				<td class="previous-month-day">
					<span>
						<!--a href="{$root}/calendar/day/{$year}/{$month}/{$day-dd}/"-->
							<xsl:value-of select="$this-day-int"/>
					</span>
				</td>
			</xsl:if>
		</xsl:when>
		<xsl:when test="$day-int &gt; $count">
			<xsl:if test="/data/clients/entry/administrator = 'No'">
				<td class="next-month-day">
					<span>
						<xsl:value-of select="$this-day-int"/>
					</span>
				</td>
			</xsl:if>
			<xsl:if test="/data/clients/entry/administrator = 'Yes'">
				<td class="previous-month-day">
					<span>
						<!--a href="{$root}/calendar/day/{$year}/{$month}/{$day-dd}/"-->
							<xsl:value-of select="$this-day-int"/>
					</span>
				</td>
			</xsl:if>
		</xsl:when>
		<xsl:when test="$index &gt; $start - 1">
			<td>
				<xsl:choose>
					<xsl:when test="$is-today = 1 and (normalize-space($week-day) = 'Saturday' or normalize-space($week-day) = 'Sunday')">
						<xsl:attribute name="class">today weekend</xsl:attribute>
					</xsl:when>
					<xsl:when test="$is-past = 1 and $day-int = $day and $is-today = 1">
						<xsl:attribute name="class">today</xsl:attribute>
					</xsl:when>
					<xsl:when test="$is-past = 1 and $day-int = $day and $is-today != 1">
						<xsl:attribute name="class">past</xsl:attribute>
					</xsl:when>
					<xsl:when test="$is-today = 1 and $is-vacation = 1">
						<xsl:attribute name="class">today vacation</xsl:attribute>
					</xsl:when>
					<xsl:when test="$is-today = 1">
						<xsl:attribute name="class">today</xsl:attribute>
					</xsl:when>
					<xsl:when test="$is-past = 1 and $day-int != $day">
						<xsl:attribute name="class">past</xsl:attribute>
					</xsl:when>
					<xsl:when test="$is-tomorrow = 1 and $is-vacation = 1">
						<xsl:attribute name="class">tomorrow vacation</xsl:attribute>
					</xsl:when>
					<xsl:when test="$is-vacation = 1">
						<xsl:attribute name="class">vacation</xsl:attribute>
					</xsl:when>
					<xsl:when test="$is-blocked = 1 and $is-tomorrow = 1">
						<xsl:attribute name="class">tomorrow blocked</xsl:attribute>
					</xsl:when>
					<xsl:when test="$is-blocked = 1">
						<xsl:attribute name="class">blocked</xsl:attribute>
					</xsl:when>
					<xsl:when test="$is-tomorrow = 1 and (normalize-space($week-day) = 'Saturday' or normalize-space($week-day) = 'Sunday')">
						<xsl:attribute name="class">tomorrow weekend</xsl:attribute>
					</xsl:when>
					<xsl:when test="normalize-space($week-day) = 'Saturday' or normalize-space($week-day) = 'Sunday'">
						<xsl:attribute name="class">weekend</xsl:attribute>
					</xsl:when>
					<xsl:when test="$is-tomorrow = 1">
						<xsl:attribute name="class">tomorrow</xsl:attribute>
					</xsl:when>
					<xsl:when test="normalize-space($is-a-full-day) = 1">
						<xsl:attribute name="class">filled</xsl:attribute>
					</xsl:when>
				</xsl:choose>
				<span>
					<xsl:choose>
						<xsl:when test="/data/clients/entry/administrator = 'Yes'">
							<a href="{$root}/calendar/day/{$year}/{$month}/{$day-dd}/">
								<xsl:value-of select="$day-int"/>
							</a>
						</xsl:when>
						<xsl:otherwise>
							<xsl:choose>
								<xsl:when test="$is-past = 1 or $is-vacation = 1 or $is-blocked = 1 or $is-tomorrow = 1 or substring(normalize-space($week-day),2) = 'aturday' or substring(normalize-space($week-day),2) = 'unday'">
									<xsl:value-of select="$day-int"/>
								</xsl:when>
								<xsl:when test="$day-int">
									<a href="{$root}/calendar/day/{$year}/{$month}/{$day-dd}/">
										<xsl:value-of select="$day-int"/>
									</a>
								</xsl:when>
							</xsl:choose>
						</xsl:otherwise>
					</xsl:choose>
				</span>
				<!-- CONTINUE FROM HERE??? -->
				<!--xsl:if test="normalize-space($is-past) = 1 and /data/clients/entry/administrator = 'Yes'">
					<p>past</p>
				</xsl:if-->
				
				<xsl:if test="normalize-space($is-past) != 1 or normalize-space($is-today) = 1">
					
					<xsl:choose>
						<xsl:when test="$is-tomorrow = 1">
							<p class="tomorrow">Tomorrow</p>
						</xsl:when>
						<xsl:when test="$is-today = 1">
							<p class="today">Today</p>
						</xsl:when>
					</xsl:choose>
					
					<xsl:choose>
						<xsl:when test="normalize-space($is-today) = 1 or normalize-space($is-tomorrow) = 1">
							<ul class="view-appointments">
								<xsl:for-each select="appointments/entry[appointment-date = normalize-space($this-date)]">
									<xsl:if test="//front-end-authentication/@user = email">
										<li>
											<xsl:attribute name="class">mine</xsl:attribute>
											<em>
												<xsl:call-template name="get-formatted-time">
													<xsl:with-param name="time" select="appointment-date/@time"/>
												</xsl:call-template>
												<img src="{$root}/workspace/images/locked.png" alt="Appointment locked, call to change or cancel" />
											</em>
										</li>
									</xsl:if>
									<xsl:if test="/data/clients/entry/administrator = 'Yes'">
										<li>
											<xsl:attribute name="class">admin</xsl:attribute>
											<form id="delete-apt-{@id}" action="" method="post">
												<fieldset>
													<input name="id" value="{@id}" type="hidden" />
													<strong>
														<!--a href="{$root}/profile/" title="{name}: {email}"-->
															<xsl:value-of select="name"/>
														<!--/a-->
													</strong>
													<em>
														<xsl:call-template name="get-formatted-time">
															<xsl:with-param name="time" select="appointment-date/@time"/>
														</xsl:call-template>
														<input class="cancel-apt" name="action[delete-apt]" type="image" src="{$root}/workspace/images/delete.png" value="Cancel Appointment" />
													</em>
												</fieldset>
											</form>
										</li>
									</xsl:if>
								</xsl:for-each>
							</ul>
						</xsl:when>
						<xsl:otherwise>
							<ul class="view-appointments">
								<xsl:for-each select="appointments/entry[appointment-date = normalize-space($this-date)]">
									<xsl:if test="//front-end-authentication/@user = email">
										<li>
											<xsl:attribute name="class">mine</xsl:attribute>
											<form id="delete-apt-{@id}" action="" method="post">
												<fieldset>
													<input name="id" value="{@id}" type="hidden" />
													<em>
														<xsl:call-template name="get-formatted-time">
															<xsl:with-param name="time" select="appointment-date/@time"/>
														</xsl:call-template><input class="cancel-apt" name="action[delete-apt]" type="image" src="{$root}/workspace/images/delete.png" value="Cancel Appointment" />
													</em>
												</fieldset>
											</form>
										</li>
									</xsl:if>
									<xsl:if test="/data/clients/entry/administrator = 'Yes'">
										<li>
											<xsl:attribute name="class">admin</xsl:attribute>
											<form id="delete-apt-{@id}" action="" method="post">
												<fieldset>
													<input name="id" value="{@id}" type="hidden" />
													<strong>
														<!--a href="{$root}/profile/" title="{name}: {email}"-->
															<xsl:value-of select="name"/>
														<!--/a-->
													</strong>
													<em>
														<xsl:call-template name="get-formatted-time">
															<xsl:with-param name="time" select="appointment-date/@time"/>
														</xsl:call-template><input class="cancel-apt" name="action[delete-apt]" type="image" src="{$root}/workspace/images/delete.png" value="Cancel Appointment" />
													</em>
												</fieldset>
											</form>
										</li>
									</xsl:if>
								</xsl:for-each>
							</ul>
						</xsl:otherwise>
					</xsl:choose>
					<xsl:choose>
						<xsl:when test="normalize-space($week-day) = 'Saturday' or normalize-space($week-day) = 'Sunday'">
							<!--p><xsl:value-of select="normalize-space($week-day)"/></p-->
						</xsl:when>
						<xsl:when test="normalize-space($is-a-full-day) = 1 and normalize-space($is-tomorrow) != 1 and normalize-space($is-today) != 1">
							<p>Day Filled</p>
						</xsl:when>
						<!--xsl:when test="normalize-space($is-vacation = 1)">
							<p>Closed</p>
						</xsl:when>
						<xsl:when test="normalize-space($is-blocked = 1)">
							<p>Day Blocked</p>
						</xsl:when>
						<xsl:when test="normalize-space($is-tomorrow = 1)">
							<p>Tomorrow</p>
						</xsl:when-->
					</xsl:choose>
					
					<xsl:choose>
						<xsl:when test="$is-vacation = 1 or $is-blocked = 1">
							<p>
								<xsl:choose>
									<xsl:when test="$is-vacation = 1">
										<xsl:text>Closed</xsl:text>
									</xsl:when>
									<xsl:when test="($is-today = 1 or $is-tomorrow = 1) and $is-blocked = 1">
										<xsl:text>Day Blocked </xsl:text>
									</xsl:when>
									<xsl:when test="$is-today = 1">
									</xsl:when>
									<xsl:when test="$is-blocked = 1">
										<xsl:text>Day Blocked </xsl:text>
									</xsl:when>
								</xsl:choose>
							</p>
						</xsl:when>
					</xsl:choose>
					
				</xsl:if>
				
				<!--xsl:if test="$is-holiday = 1">
					<p class="holiday">
						<xsl:value-of select="iCalendar/vcalendar[@x-wr-calname='Holidays']/vevent[substring(dtstart,5) = $this-month-day]/summary"/>
					</p>
				</xsl:if-->
			
			</td>
		</xsl:when>
	</xsl:choose>
	<xsl:if test="$counter &gt; $index">
		<xsl:call-template name="days">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
			<xsl:with-param name="day" select="$day"/>
			<xsl:with-param name="index" select="$index + 1"/>
			<xsl:with-param name="counter" select="$counter"/>
		</xsl:call-template>
	</xsl:if>
</xsl:template>
<xsl:template name="month-days">
	<xsl:param name="date"/>
	<xsl:param name="year" select="substring($date,1,4)"/>
	<xsl:param name="month" select="substring($date,6,2)"/>
	<xsl:param name="month-int" select="format-number($month,'0')"/>
	<xsl:param name="leap-year">
		<xsl:call-template name="is-leap-year">
			<xsl:with-param name="year" select="$year"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:choose>
		<xsl:when test="$month-int!=2">
			<xsl:value-of select="/data/calendar/year/month[@value=$month-int]/@days"/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:choose>
				<xsl:when test="$leap-year!=1">
					<xsl:value-of select="/data/calendar/year/month[@value=2]/@days"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="/data/calendar/year/month[@value=2]/@leap-year-days"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
<xsl:template name="previous-month">
	<xsl:param name="date"/>
	<xsl:param name="year" select="substring($date,1,4)"/>
	<xsl:param name="month" select="substring($date,6,2)"/>
	<xsl:choose>
		<xsl:when test="$month - 1 &lt; 1">12</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="format-number($month - 1,'00')"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
<xsl:template name="next-month">
	<xsl:param name="date"/>
	<xsl:param name="year" select="substring($date,1,4)"/>
	<xsl:param name="month" select="substring($date,6,2)"/>
	<xsl:choose>
		<xsl:when test="$month + 1 &gt; 12">01</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="format-number($month + 1,'00')"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
<xsl:template name="previous-month-year">
	<xsl:param name="date"/>
	<xsl:param name="year" select="substring($date,1,4)"/>
	<xsl:param name="month" select="substring($date,6,2)"/>
	<xsl:choose>
		<xsl:when test="$month != 1">
			<xsl:value-of select="$year"/>
		</xsl:when>
		<xsl:when test="$month = 1">
			<xsl:value-of select="$year - 1"/>
		</xsl:when>
		<xsl:otherwise>0</xsl:otherwise>
	</xsl:choose>
</xsl:template>
<xsl:template name="next-month-year">
	<xsl:param name="date"/>
	<xsl:param name="year" select="substring($date,1,4)"/>
	<xsl:param name="month" select="substring($date,6,2)"/>
	<xsl:choose>
		<xsl:when test="$month &lt; 12">
			<xsl:value-of select="$year"/>
		</xsl:when>
		<xsl:when test="$month = 12">
			<xsl:value-of select="$year + 1"/>
		</xsl:when>
		<xsl:otherwise>0</xsl:otherwise>
	</xsl:choose>
</xsl:template>
<xsl:template name="next-day">
	<xsl:param name="date"/>
	<xsl:param name="year" select="substring($date,1,4)"/>
	<xsl:param name="month" select="substring($date,6,2)"/>
	<xsl:param name="day" select="substring($date,9,2)"/>
	<xsl:param name="month-days">
		<xsl:call-template name="month-days">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="next-month">
		<xsl:call-template name="next-month">
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="next-month-year">
		<xsl:call-template name="next-month-year">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:choose>
		<xsl:when test="$day + 1 &gt; $month-days">
			<xsl:value-of select="concat($next-month-year,'-',$next-month,'-01')"/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="concat($year,'-',$month,'-',format-number($day + 1,'00'))"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
<xsl:template name="previous-week">
	<xsl:param name="date"/>
	<xsl:param name="year" select="substring($date,1,4)"/>
	<xsl:param name="month" select="substring($date,6,2)"/>
	<xsl:param name="day" select="substring($date,9,2)"/>
	<xsl:param name="previous-month">
		<xsl:call-template name="previous-month">
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="previous-month-year">
		<xsl:call-template name="previous-month-year">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="previous-month-days">
		<xsl:call-template name="month-days">
			<xsl:with-param name="year" select="$previous-month-year"/>
			<xsl:with-param name="month" select="$previous-month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:choose>
		<xsl:when test="$day - 7 &lt; 1 and $month = 1">
			<xsl:value-of select="concat($previous-month-year,'-',$previous-month,'-',format-number($previous-month-days - (7 - $day),'00'))"/>
		</xsl:when>
		<xsl:when test="$day - 7 &lt; 1 and $month &gt; 1">
			<xsl:value-of select="concat($year,'-',$previous-month,'-',format-number($previous-month-days - (7 - $day),'00'))"/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="concat($year,'-',$month,'-',format-number($day - 7,'00'))"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
<xsl:template name="next-week">
	<xsl:param name="date"/>
	<xsl:param name="year" select="substring($date,1,4)"/>
	<xsl:param name="month" select="substring($date,6,2)"/>
	<xsl:param name="day" select="substring($date,9,2)"/>
	<xsl:param name="month-days">
		<xsl:call-template name="month-days">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="next-month">
		<xsl:call-template name="next-month">
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="next-month-year">
		<xsl:call-template name="next-month-year">
			<xsl:with-param name="year" select="$year"/>
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:choose>
		<xsl:when test="$day + 7 &gt; $month-days">
			<xsl:value-of select="concat($next-month-year,'-',$next-month,'-',format-number($day + 7 - $month-days,'00'))"/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="concat($year,'-',$month,'-',format-number($day + 7,'00'))"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
<xsl:template name="previous-month-days">
	<xsl:param name="date"/>
	<xsl:param name="year" select="substring($date,1,4)"/>
	<xsl:param name="month" select="substring($date,6,2)"/>
	<xsl:param name="previous-month">
		<xsl:call-template name="previous-month">
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="leap-year">
		<xsl:call-template name="is-leap-year">
			<xsl:with-param name="year" select="$year"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:call-template name="month-days">
		<xsl:with-param name="leap-year" select="$leap-year"/>
		<xsl:with-param name="month" select="$previous-month"/>
	</xsl:call-template>
</xsl:template>
<xsl:template name="next-month-days">
	<xsl:param name="date"/>
	<xsl:param name="year" select="substring($date,1,4)"/>
	<xsl:param name="month" select="substring($date,6,2)"/>
	<xsl:param name="next-month">
		<xsl:call-template name="next-month">
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="leap-year">
		<xsl:call-template name="is-leap-year">
			<xsl:with-param name="year" select="$year"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:call-template name="month-days">
		<xsl:with-param name="leap-year" select="$leap-year"/>
		<xsl:with-param name="month" select="$next-month"/>
	</xsl:call-template>
</xsl:template>
<xsl:template name="week-number">
	<xsl:param name="date" select="$today"/>
	<xsl:param name="year" select="substring($date, 1, 4)" />
	<xsl:param name="leap" select="(not($year mod 4) and $year mod 100) or not($year mod 400)" />
	<xsl:param name="month" select="substring($date, 6, 2)" />
	<xsl:param name="day" select="substring($date, 9, 2)" />
	<xsl:param name="month-days">
		<xsl:call-template name="month-days">
			<xsl:with-param name="leap-year" select="$leap"/>
			<xsl:with-param name="month" select="$month"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="days">
		<xsl:choose>
			<xsl:when test="$leap and $month > 2">
				<xsl:value-of select="$month-days + $day + 1" />
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$month-days + $day" />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:param>
	<xsl:param name="y-1" select="$year - 1" />
	<xsl:param name="day-of-week" 

      select="(($y-1 + floor($y-1 div 4) -
           floor($y-1 div 100) + floor($y-1 div 400) +
           $days) 
           mod 7) + 1" />
	<xsl:choose>
		<xsl:when test="($day - $day-of-week) mod 7">
			<xsl:value-of select="floor(($day - $day-of-week) div 7) + 2" />
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="floor(($day - $day-of-week) div 7) + 1" />
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
<xsl:template name="full-day">
	<xsl:param name="date"/>
	<xsl:param name="week-day">
		<xsl:call-template name="get-day-of-the-week-name">
			<xsl:with-param name="date" select="normalize-space($date)"/>
		</xsl:call-template>
	</xsl:param>
	<xsl:param name="num-apts" select="count(appointments/entry[appointment-date = normalize-space($date)])"/>
	<xsl:param name="num-slots" select="count(/data/time-schedule/entry[weekday = normalize-space($week-day)]/available-times/item)"/>
	<xsl:if test="normalize-space($num-apts) = normalize-space($num-slots)">1</xsl:if>
</xsl:template>

</xsl:stylesheet>
